package tmt.usercenter.web.vo;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.URL;
import tmt.usercenter.web.domain.ClientSystem;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Getter
@Setter
public class ClientVo implements Serializable {

	private String logo;

	@NotBlank
	private String name;
	@NotBlank
	private String clientId;
	@NotBlank
	private String description;
	private List<String> scopes;
	@NotBlank
	@Email
	private String email;
	@NotBlank
	@URL
	private String registeredRedirectUri;
	@URL
	private String changedNotifyUrl;

	public ClientSystem toClient() {
		ClientSystem client = new ClientSystem();
		client.setName(name);
		client.setDescription(description);
		client.setScope(scopes);
		client.setEmail(email);
		client.setRegisteredRedirectUri(Arrays.asList(registeredRedirectUri));
		client.setChangedNotifyUrl(changedNotifyUrl);
		return client;
	}
}
